<template>
  <!-- 设置估价对话框 -->
  <el-dialog title="修改" :visible.sync="openWarehousePropertyDetailEdit" width="800px" append-to-body :destroy-on-close="true" :before-close="beforeClose">
    <el-form ref="formParams" label-width="120px" :inline="true">
      <el-row>
        <el-col :span="12">
          <el-form-item label="旧货权人" prop="sptm">
            <el-input
            v-model="formParams.khmc"
            :disabled="true"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="新货权人" prop="khmcn">
            <el-input
            v-model="formParams.khmcn"
            :disabled="true"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="转移件数" prop="spjs">
            <el-input
            v-model="formParams.spjs"
            :disabled="true"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="单重(Kg)" prop="spjsl">
            <el-input
            v-model="formParams.spjsl"
            :disabled="true"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="重量(吨)" prop="spsl">
            <el-input
            v-model="formParams.spsl"
            :disabled="true"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="货权转移支付方" prop="hqf">
            <el-select
              v-model="formParams.hqf"
              placeholder="请选择"
              clearable
            >
              <el-option
                  v-for="(item, index) in PropertyPayType"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
         <el-col :span="12">
          <el-form-item label="货权转移时间" prop="ssrqid">
            <el-date-picker
              v-if="formParams.ssrqid"
              v-model="formParams.ssrqid"
              value-format="yyyy-MM-dd"
              type="date"
              placeholder="请输入货权转移时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注" prop="spbz">
            <el-input
              v-model="formParams.spbz"
              placeholder="请输入备注"
              clearable
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleEdit" v-hasPermi="['zhcloud:hqzy:modify']">修 改</el-button>
      </div>
  </el-dialog>
</template>

<script>
import { warehousePropertyModify } from "@/api/storage/commonGoods/warehouseProperty";

export default {
  name: "WarehousePropertyDetailEdit",
  data() {
    return {
      PropertyPayType:[
        {label:"旧货权方", value:"0"},
        {label:"新货权方", value:"1"},
        {label:"免收费用", value:"1"},
      ],
      //弹窗状态
      openWarehousePropertyDetailEdit: false,
      formParams: {
        khmc:"",
        khmcn:"",
        spjs:"",
        spjsl:"",
        spsl:"",
        dzid: 0,
        hqf: "",
        spbhid2: "",
        spbz: "",
        spdzld1: 0,
        spdzld2: 0,
        ssrqid: ""
      }
    };
  },
  methods: {
    /**修改 */
    handleWarehousePropertyModify() {
      this.$modal.loading("数据正在修改中，请稍等...")
      warehousePropertyModify(this.formParams).then(response => {
        this.$modal.closeLoading()
        this.$modal.msgSuccess('修改成功！')
        this.close()
        this.$emit('refresh', true)
      }).catch(()=> {
        this.$modal.closeLoading()
      })
    },
    //修改详情
    handleEdit() {
        this.$modal.confirm("是否修改？").then(()=> {
            this.handleWarehousePropertyModify()
        }).catch(() => {})
    },
    /**关闭弹窗 */
    beforeClose(done) {
      this.close()
      done()
    },
    /**关闭窗口 */
    close() {
      this.changeWarehousePropertyDetailEdit()
      this.$emit('refresh', true)
    },
    /**改变窗口状态 */
    changeWarehousePropertyDetailEdit() {
      this.openWarehousePropertyDetailEdit = !this.openWarehousePropertyDetailEdit;
    },

    /**打开弹窗 */
    open(row, dzid) {
      this.changeWarehousePropertyDetailEdit()
      const { khmc="",khmcn="",spjs="",spjsl="",spsl="",hqf2:hqf,spbhidn:spbhid2,itbz:spbz,spdzld:spdzld1,spdzld2= 0,ssrqidn:ssrqid} = row
      this.formParams = {...this.fromParams,khmc,khmcn,spjs,spjsl,spsl,hqf,spbhid2,spbz,spdzld1,spdzld2,ssrqid}
      this.formParams.dzid = dzid
    }
  }
}
</script>
